#include<bits/stdc++.h>
using uint=unsigned int;
using ll=long long;
using ull=unsigned long long;
using pii=std::pair<int,int>;
#define fst first
#define scd second
#define all(x) std::begin(x),std::end(x)
#define y0 y000000
#define y1 y111111
#define rep(i,s,t) for(int i=(s);i<=(t);i++)
#define irep(i,s,t) for(int i=(s);i>=(t);i--)
template<typename T> bool chmax(T &x,T const &y){
    return x<y?x=y,true:false;
}
template<typename T> bool chmin(T &x,T const &y){
    return y<x?x=y,true:false;
}
using namespace std;
const int N=1e5+10;
int n,v[N],f[N];
signed main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    ios::sync_with_stdio(false);
    cin>>n;
    map<int,int> cnt;
    rep(i,1,n) cin>>v[i],cnt[v[i]]++;
    sort(v+1,v+1+n);
    f[0]=0;
    rep(i,1,n){
        f[i]=f[i-1]+1;
        if(v[i]>v[i-1-f[i-1]+1]) f[i]--;
    }
    // int mn=INT_MAX,c=0;
    // irep(i,n,2){
    //     if(chmin(mn,v[i])) c=1;
    //     int gr=(n-i+1)-c;
    //     if((n-i+1)>=f[i-1]&&gr>=cnt[mn]-c){
    //         cout<<n-i+1<<'\n';
    //         return 0;
    //     }
    // }
    // cout<<n<<'\n';
    cout<<f[n]<<'\n';
}